<?php

/*
  VoIP Wholesale 1.0
  ------------------
  Document   : module_external_home
  Created on : Sep 14, 2011, 4:32:27 PM
  Author     : Milos Jovanovic <miloscode@gmail.com>
  Description:

 */
?>
<div id="page-title"><?=lang('term_carriers')?></div>

<div id="page-desc"><?=lang('text_carriers_desc')?></div>

<div class="ui-widget"> 
    <div id="content">
        <!-- PAGE CONTENT -->
        <div class="module-options">
            <button id="module-add-new"><?=lang('button_add_new_carrier')?></button>
        </div>
        
        <fieldset class="ui-widget-content ui-state-active">

            <legend class="ui-widget-content ui-state-active"><?=lang('form_filters')?></legend>
                
            <form action="<?=MODULE_SITE_URL?>/" method="post">
                <table>
                <tr>
                    <td>
                        <select name='data[country_id]' id="country" <?php if(isset($country_id) && $country_id != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_country')?></option>
                            <?php
                            foreach($countries as $country)
                            {
                            ?>
                            <option value="<?=$country->id?>" <?php if(@$country_id == $country->id){?>selected="selected"<?php }?>><?=$country->country_name?></option>
                            <?php        
                              }
                            ?>
                        </select>
                    </td>
                    <td>
                            <input type="text" name="data[username]" value="<?php if(isset($username) && strlen($username)>0 && strtoupper($username) != strtoupper(lang('term_username'))){print $username;}else{print lang('term_username');}?>" id="username_field" <?php if(isset($username)  && strlen($username)>0 && strtoupper($username) != strtoupper(lang('term_username'))){?>class="ui-state-error"<?php }?>/>
                    </td>
                    <td>
                        <select name="data[contract_type]" <?php if(isset($contract_type) && @$contract_type != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('term_contract_type')?></option>
                            <option value="bi_lateral" <?php if(@$contract_type == "bi_lateral"){?>selected="selected"<?php }?>><?=lang('term_bilateral')?></option>
                            <option value="we_buy_from_them" <?php if(@$contract_type == "we_buy_from_them"){?>selected="selected"<?php }?>><?=lang('term_we_buy_from_them')?></option>
                            <option value="we_sell_to_them" <?php if(@$contract_type == "we_sell_to_them"){?>selected="selected"<?php }?>><?=lang('term_we_sell_to_them')?></option>
                        </select>
                    </td>
					<td>
                        <select name="data[service_type]" <?php if(isset($service_type) && @$service_type != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('term_service_type')?></option>			
							<option value="special_services" <?php if(@$service_type == "special_services"){?>selected = "selected"<?php }?>>
								<?=lang('text_special_services_abbreviation')?> - <?=lang('text_special_services')?>
							</option>			
							<option value="wholesale" <?php if(@$service_type == "wholesale"){?>selected = "selected"<?php }?>>
								<?=lang('text_wholesale_abbreviation')?> - <?=lang('text_wholesale')?>
							</option>			
						</select>	
					</td>					
                    <td>
                        <select name="data[status]" <?php if(isset($status) && @$status != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_status')?></option>
                            <option value="all" <?php if(@$status == "all"){?>selected="selected"<?php }?>><?=lang('term_all')?></option>
                            <option value="active" <?php if(@$status == "active"){?>selected="selected"<?php }?>><?=lang('term_active')?></option>
                            <option value="inactive" <?php if(@$status == "inactive"){?>selected="selected"<?php }?>><?=lang('term_inactive')?></option>					
                        </select>
                    </td>
                    <td>
                        <select name="data[num_of_results]" <?php if(isset($num_of_results) && @$num_of_results != "none"){?>class="ui-state-error"<?php }?>>
                            <option value="none"><?=lang('form_max_results')?></option>
                            <option value="20" <?php if(@$num_of_results == "20"){?>selected="selected"<?php }?>>20</option>
                            <option value="50" <?php if(@$num_of_results == "50"){?>selected="selected"<?php }?>>50</option>
                            <option value="100" <?php if(@$num_of_results == "100"){?>selected="selected"<?php }?>>100</option>
                            <option value="200" <?php if(@$num_of_results == "200"){?>selected="selected"<?php }?>>200</option>
                            <option value="500" <?php if(@$num_of_results == "500"){?>selected="selected"<?php }?>>500</option>
                        </select>
                    </td>
                    <td>
                            <button id="filter-submit"><?=lang('term_search')?></button>
                    </td>
                </tr>
                </table>
            </form>                
        </fieldset>
        <br />
        <!-- table with the entries -->
	<table class="ui-widget ui-widget-content module-table-num-plan" id="module-carriers-table"> 
		<thead> 
			<tr class="ui-widget-header "> 
				<!--<th class="module-1st">#</th> -->
				<th class="module-2nd"><?=lang('term_username')?></th> 
                <th class="module-3rd"><?=lang('term_legal_name')?></th> 
				<th class="module-4th"><?=lang('term_currency')?></th> 												
				<th class="module-5th"><?=lang('term_carrier_balance')?></th> 												
                <th class="module-6th"><?=lang('term_carrier_credit_limit')?></th> 				
				<th class="module-7th"><?=lang('term_company_balance')?></th> 												
                <th class="module-8th"><?=lang('term_company_credit_limit')?></th> 
				<th class="module-9th"><?=lang('term_service_type')?></th> 
                <th class="module-10th"></th> 
                <th class="module-11th"></th> 
			</tr> 
		</thead> 
		<tbody> 
		<?php $num=1;
		if(is_array($carriers)){
		foreach($carriers as $carrier){
		$country = $this->PACKAGE->regional->countries->get_country_as_array_from_id($carrier['country_id']);
		$currency = $this->PACKAGE->regional->currencies->get_currency_as_array_from_id($carrier['currency_id']);?>
			<tr id="anchor_<?=$carrier['id']?>"> 
                <!--<td><?=$num?></td>-->
                <td class="module-2nd status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['username']?></td> 
                <td class="module-3rd status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['legal_name']?></td> 
				<td class="module-4th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$currency['iso_4217']?></td>
				<td class="module-5th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['carrier_balance']?></td> 				
				<td class="module-6th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['carrier_credit_limit']?></td> 
				<td class="module-7th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['company_balance']?></td> 				
				<td class="module-8th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>"><?=$carrier['company_credit_limit']?></td> 				
				<td class="module-9th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>">
					<?php if($carrier['special_numbers_only']){?><?=lang('text_special_services_abbreviation')?><?php }
					else{?><?=lang('text_wholesale_abbreviation')?><?php }?>
				</td> 
				<td class="module-10th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>">
					<button class="edit carrier_button_<?=$carrier['id']?>" name="<?=$carrier['id']?>" rel="<?=$carrier['status']?>">
						<span><?=lang('button_edit')?></span>
					</button>
				</td>		
				<td class="module-11th status_<?=$carrier['status']?> carrier_no_<?=$carrier['id']?>">
					<button class="options carrier_button_<?=$carrier['id']?>" id="<?=$carrier['id']?>" rel="<?=$carrier['status']?>" title="<?=$carrier['username']?>">
						<span class="carrier_button_span_<?=$carrier['id']?>">
							<?php if($carrier['status']){?>
								<?=lang('button_enabled')?>				
							<?php } else {?>
								<?=lang('button_disabled')?>
						<?php }?>
						</span>
					</button>
				</td> 				
			</tr> 
		<?php 
		$num++;}}?>
		</tbody> 
	</table> 
    </div>    
</div>   
<div class="footnote">
	* <?=lang('text_special_services_abbreviation')?> = <?=lang('text_special_services')?><br />
	* <?=lang('text_wholesale_abbreviation')?> = <?=lang('text_wholesale')?>
</div>
<div id="enable">
	<p>
		<?=lang('text_are_you_sure_you_want_to_enable_carrier')?>
		<span class="carrier_name"></span>?
	</p>
</div>
<div id="disable">
	<p>
		<?=lang('text_are_you_sure_you_want_to_disable_carrier')?>
		<span class="carrier_name"></span>?
	</p>
</div>